﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace tscsclassgen
{
    /// <summary>
    /// AlternativeTypeSelectorDialog.xaml の相互作用ロジック
    /// </summary>
    public partial class AlternativeTypeSelectorDialog : Window
    {
        public string Selection = null;
        public AlternativeTypeSelectorDialog(IEnumerable<string> allTypes)
        {
            InitializeComponent();
            ListBoxTypes.Items.Clear();
            foreach (var item in allTypes)
            {
                ListBoxTypes.Items.Add(item);
            }
        }

        private void OK_Click(object sender, RoutedEventArgs e)
        {
            okCloseRequest();
        }

        private void Cancel_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = false;
        }

        private void ListBoxTypes_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            okCloseRequest();
        }

        private void okCloseRequest()
        {
            Selection = (string)ListBoxTypes.SelectedItem;
            if (Selection == null)
            {
                MessageBox.Show("Please select one type name.");
                return;
            }
            DialogResult = true;
        }
    }
}
